<template>
  <div class="login-page">
    <div class="login-header">
      <div class="login-logo">
        <div class="login-title">后台管理系统</div>
      </div>
    </div>
    <div class="login-body">
      <div class="login-left">
        <div class="login-desc">

        </div>
      </div>
      <div class="login-form">
        <div class="login-form-title">登录</div>
        <div class="login-form-desc">请填写您的账号和密码</div>
        <el-form ref="loginForm" label-position="top" :model="loginForm" :rules="rules">
          <el-form-item label="账号" prop="username">
            <el-input v-model="loginForm.username" size="medium" type="text" placeholder="请输入账号"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input v-model="loginForm.password" size="medium"  type="password" show-password placeholder="请输入您的密码"></el-input>
          </el-form-item>
          <el-form-item label="" style="margin-top: 20px">
            <el-button :loading="loading" style="width: 100%" type="primary" size="medium" @click="_login">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
import {mapActions} from "vuex";
export default {
  data() {
    return {
      loading: false,
      loginForm: {
        username: "admin",
        password: "123456",
      },
      rules: {
        username: [
          { required: true, message: "请输入您的账号", trigger: "blur" },
        ],
        password: [
          { required: true, message: "请输入您的密码", trigger: "blur" },
        ],
      }
    }
  },
  methods: {
    ...mapActions("user", ["login","getLoginCaptcha"]),
    _login() {
      this.loading = true
      this.login(this.loginForm)
          .then((res) => {
            this.loading = false;
            this.$router
                .push({
                  path: this.$route.query.redirect || "/",
                })
                .catch((err) => {});
          })
          .catch((error) => {
            this.loading = false;
          });
    },
  }
}
</script>
<style lang="scss">
.login-page {
  background-color: #fafbfe;
  .login-header {
    max-width: 1050px;
    margin: 0 auto 30px;
    padding: 1.5rem 0;
    display: flex;
    justify-content: space-between;
  }
  .login-logo {
    display: flex;
    align-items: center;
    .login-title {
      margin-left: 12px;
      font-size: 24px;
      font-weight: bold;
    }
  }
  .login-body {
    overflow: hidden;
    max-width: 1050px;
    position: relative;
    display: flex;
    align-items: center;
    flex-direction: row;
    margin: 0 auto;
    box-shadow: 0 19px 22px #e8ecf4;
    background-color: #ffffff;
    border-radius: 0 2% 2% 0;
    .login-left {
      height: 520px;
      background: #1e2a35;
      flex: 1;
      position: relative;
      color: #fff;
      vertical-align: middle;
      display: flex;
      flex-flow: column;
      align-items: center;
      justify-content: center;
      border-radius: 2% 0 0 2%;
      .login-desc {
        margin-top: 20px;
        font-size: 22px;
        max-width: 700px;
        font-weight: 200;
        line-height: 31px;
      }
    }
    .login-form {
      height: 520px;
      max-width: 500px;
      padding: 3rem 2rem;
      background-color: #fff;
      position: relative;
      width: 100%;
      align-items: center;
      border-radius: 0 2% 2% 0;
      box-sizing: border-box;
      overflow: hidden;
      .el-form-item {
        margin-bottom: 1rem;
      }
      .login-form-title {
        color: #6c757d;
        font-size: 18px;
        font-weight: 700;
        margin-bottom: 10px;
      }
      .login-form-desc {
        color: #98a6ad;
        font-size: 14px;
        font-weight: 400;
        margin-bottom: 1em;
      }
      .el-form-item__label {
        color: #6c757d;
        font-weight: 600;
        font-size: 14px;
        padding-bottom: 4px;
      }
    }
  }

  .jc-range {
    background-color: #e8e8e8;
  }
}
</style>
